package io.renren.mqtt;

import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.integration.mqtt.core.MqttPahoClientFactory;
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;

public class CustomMqttPahoMessageDrivenChannelAdapter extends MqttPahoMessageDrivenChannelAdapter {

    public CustomMqttPahoMessageDrivenChannelAdapter(String clientId, MqttPahoClientFactory clientFactory, String... topics) {
        super(clientId, clientFactory, topics);
    }

    @Override
    public void connectionLost(Throwable cause) {
        // 连接丢失时手动抛出异常以触发重试
        try {
            throw new MqttException(MqttException.REASON_CODE_CLIENT_DISCONNECTING);
        } catch (MqttException e) {
            throw new RuntimeException(e);
        }
    }
}

